Git 常用命令
tag:
| 1 | # create a new tag | 
undo all uncommit changes:
| 1 | 1. git clean -fd # delete all untracked files and directories | 
pring branch tree
在.gitconfig 中添加:
| 1 | [alias] | 
使用命令git lg就可以在命令行中看到branch tree 了
Reference:
回滚到指定 commit id
| 1 | git reset --hard 0682c06 | 
有时需要撤销以前的单个或多个 commit, 可用以下命令:1
2
3
4git revert -n <commit id> # -n means --no-commit, 否则 git 在 revert 之后会自动 commit.
git revert -n <commit id> # 可以连续执行多次, 以 revert 多个 commit.
git commit -m "revert commit_id1 and commit_id2"
 也可以用 git revert --continue, 来提交. 但默认的注释只包含第一次 revert 的 commit id.
Reference
- https://stackoverflow.com/a/1895095/5432806
- http://serebrov.github.io/html/2014-01-04-git-revert-multiple-recent-comments.html
- https://stackoverflow.com/a/4114122/5432806
save HTTPS account
- (Recommended) attach credential to remote repository url: https://username:password@git.coding.net/username/repository.git
- store temporarily: execute command git config credential.helper 'cache --timeout=60', then credential will expire after 60 seconds since last use.
- store permanently: execute command git config --global credential.helper store, then credential will be stored in file~/.git-credentialsand~/.gitconfigpermanently.
Reference: